#include <my_header.h>
// 写端 写的数据过大将阻塞
/* Usage: ./4_read_select */
int main(int argc, char *argv[]){                                  
    int fd_write = open("shared.pipe", O_WRONLY);
    ERROR_CHECK(fd_write, -1, "open write");

    char buf[4096] = { 0 };
    int times = 0;
    // 存储文件描述符的结构体
    fd_set set;
    
    while(1)
    {
        FD_ZERO(&set);  // 初始化
        FD_SET(fd_write, &set);  // 将文件描述符添加到set
        int res_select = select(fd_write+1, NULL, &set,
                                NULL, NULL);
        ERROR_CHECK(res_select, -1, "select");
        printf("select :%d\n", ++times);    // 阻塞的时间
        write(fd_write, buf, sizeof(buf));
    }

    close(fd_write);
    return 0;
}


